package com.kzc.service.impl;

import com.kzc.base.model.Result;
import com.kzc.dao.CollectionDao;
import com.kzc.entity.Article;
import com.kzc.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author：柯尊诚
 * Created by anyleKe on 2016/2/25.
 */
@Service
public class CollectionServiceImpl implements CollectionService{

    @Autowired
    CollectionDao collectionDao;

    public Result add(Article article) {
        int i = collectionDao.add(article);
        if (i > 0) {
            return new Result(Result.SUCCESS, "添加成功");
        } else {
            return new Result(Result.ERROR, "添加失败");
        }
    }

    public Result queryCollection(String qtoken) {
        List<Article> articles = collectionDao.queryCollection(qtoken);
        if (articles.size() > 0) {
            return new Result(Result.SUCCESS, articles, "查询成功");
        } else {
            return new Result(Result.ERROR, "查询失败");
        }
    }

    public Result delete(String sysId, String qtoken) {
        int i = collectionDao.delete(sysId, qtoken);
        if (i > 0) {
            return new Result(Result.SUCCESS, "删除成功");
        } else {
            return new Result(Result.ERROR, "删除失败");
        }
    }
}
